﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Runtime.Serialization;

namespace CMD.BAL.CAT
{
   [DataContractAttribute]
   public class TipoPersonaFisica
   {
       [DataMemberAttribute(EmitDefaultValue = false)]
       public int idTipoPersonaFisical;
       [DataMemberAttribute(EmitDefaultValue = false)]
       public string dscTipoPersonaFiscal;
       //[DataMemberAttribute]
       //public Boolean isActivo;
       public static DataTable GetData()
       {
            DataTable dt;
            //ejecutar store
            dt = CMD_WEB.DAL.SrvDB.ExecuteQuery("exec SP_CMD_CAT_SEL_TIPO_PERSONA_FISICA");
            return dt;
       }
       public static List<TipoPersonaFisica> GetDataTipoPersonaFisica()
       {
           try
           {
               DataTable dt;
               dt =TipoPersonaFisica.GetData();
               if (dt.Rows.Count == 0)
               {
                   return null;
               }
               else
               {
                   List<TipoPersonaFisica> list = dt.AsEnumerable().Select(
                   row => new TipoPersonaFisica
                   {
                       idTipoPersonaFisical = row.Field<int?>("ID_TIPO_PERSONA_FISCAL").GetValueOrDefault(),
                       dscTipoPersonaFiscal = String.IsNullOrEmpty(row.Field<string>("DSC_TIPO_PERSONA_FISCAL"))
                       ? ""
                       : row.Field<string>("DSC_TIPO_PERSONA_FISCAL"),
                       //isActivo = row.Field<Boolean?>(2).GetValueOrDefault(),
                   }
                   ).ToList();
                   return list;
               }
           }
           catch (Exception ex)
           {

               throw ex;
           }
       }
       public TipoPersonaFisica() 
       {
           idTipoPersonaFisical = 0;
           dscTipoPersonaFiscal = "";
           //isActivo = false;
       }
       //public TipoPersonaFisica(int idTipoPersonaFisical, string dscTipoPersonaFiscal, Boolean isActivo) 
       public TipoPersonaFisica(int idTipoPersonaFisical,string dscTipoPersonaFiscal) 
       {
           this.idTipoPersonaFisical = idTipoPersonaFisical;
           this.dscTipoPersonaFiscal = dscTipoPersonaFiscal;
           //this.isActivo = isActivo;
       }
   }
}
